/**
 * Assignment 5               P5Box.java                Due July 20, 2011
 *
 * login: cs11ubn
 */

/**
 * Box object that inherits Rectangle. Overrides the area, volume and toString
 * methods
 */
public class P5Box extends P5Rectangle
{
  private double depth; // Holds the depth of the box

  /**
   * No-arg ctor. Initialize depth to 0
   */
  public P5Box()
  {
    super();
    depth = 0;
  }

  /**
   * 3-arg ctor. Initialize to the given width, height, and depth. Call super
   * with the given width and height
   */
  public P5Box(double w, double h, double d)
  {
    super(w , h); // Call super with 2-args
    depth = d; // Set depth
  }

  /**
   * Override the area method in Rectangle.
   */
  public double area()
  {
    // Return the sum of the 6 faces area.
    return (width * height * 2) + (width * depth * 2) + (height * depth * 2);
  }

  /**
   * Override the volume method in Rectangle
   */
  public double volume()
  {
    return super.area() * depth; // Volume is just the rectangles area * depth
  }

  /**
   * Override the toString in Rectangle.
   */
  public String toString()
  {
    return "Box:\t\t" + width + " x " + height + " x " + depth; // Box output
  }
}
